var num = 1;
var pageSize = 10;
var encodeInfo = '';
var configInfo ='';
var wholeTestResult = "success";
var encodeDesignInfo='';

var exceptionFunc="";
var encryptFunc="";
var encryptOutput="";
var exceptionRes="";
var integrityFunc="";
var integrityResArea="";



function getEncodeDesignInfo(designId){

    $.ajax({
        type: "get",
        url: HOST.concat("/encodeDesigns/designId?designId=")+designId+"&token="+config.token,
        async:false,
        dataType: "json",
        success:function (res) {
            encodeDesignInfo=res.data;
            exceptionFunc=encodeDesignInfo.exceptionFunc;
            encryptFunc=encodeDesignInfo.encryptFunc;
            encryptOutput=encodeDesignInfo.encryptOutput;
            exceptionRes=encodeDesignInfo.exceptionRes
            integrityFunc=encodeDesignInfo.integrityFunc;
            integrityResArea=encodeDesignInfo.integrityResArea;

        }
    })
}




Array.prototype.contains = function (obj) {
    var i = this.length;
    while (i--) {
        if (this[i] === obj) {
            return true;
        }
    }
    return false;
}
function getQueryString(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
    if(r != null) {
        return unescape(r[2]);
        //return decodeURI(r[2]); //解决中文乱码问题
    }
}


function listTestReport(pageNum, pageSize){
    $.ajax({
        url: HOST.concat("/testReports/username?username="+config.username+"&pageNum=" + pageNum + "&pageSize=" + pageSize + "&token=" + config.token),
        type: "GET",
        success: function(datas){
            checkLogin(datas);
            addContent(datas);
        },
        error: function(){
            console.log("请求测试报告列表错误!");
        },
        dataType: "json",
    });
}
/*function getEncodeInfo(designId) {
 $.ajax({
 url: HOST.concat("/protocolEncode/id?id="+designId+"&token=" + config.token),
 type: "GET",
 async: false,
 success: function(datas){
 checkLogin(datas);
 encodeInfo = datas.data;
 },
 error: function(){
 console.log("请求配置详情错误!");
 },
 dataType: "json",
 });
 }*/
function getConfigInfo(designId) {
    $.ajax({
        url: HOST.concat("/protocolConfigs/designId?designId="+designId+"&token=" + config.token),
        type: "GET",
        async: false,
        success: function(datas){
            checkLogin(datas);
            console.log(datas);
            configInfo = datas.data;
        },
        error: function(){
            console.log("请求配置详情错误!");
        },
        dataType: "json",
    });
}
function getReportDetail(reportId,designId){
    window.open("testReport.html?reportId="+reportId+"&designId="+designId);

}

var funcTab = {"authNego":"认证协商","encryptNego":"加密协商","encrypt":"加密","exception":"异常","virus":"病毒","resend":"重传","integrity":"完整性"};
var resultTab = {"success":"成功","fail":"失败"};

function getAllTestRes(resMap) {
    var res = '';
    resMap.forEach(function (item,key) {
        if(item=="失败"){
            res='失败';
        }
    })
    if(res==''){
        res = "成功";
    }
    return res;
}
function getLength(obj){

    var count = 0;
    for(var i in obj){
        count++;
    }
    return count;
}
function addDialogDiv(res){
    if(res.meta.state==="success") {
        console.log("有查询记录");
        var reportInfo = res.data;
        wholeTestResult = "success";
        var funcs = "";


        var ANConfigHtml = '';
        var ENConfigHtml = '';
        var EConfigHtml = '';
        var IConfigHtml = '';
        var EXConfigHtml = '';
        var RConfigHtml = '';

        var ANTestHtml = '';
        var ENTestHtml = '';
        var ETestHtml = '';
        var ITestHtml = '';
        var EXTestHtml = '';
        var RTestHtml = '';

        var ANAttHtml = '';
        var EAttHtml = '';
        var IAttHtml = '';
        var EXAttHtml = '';
        var RAttHtml = '';

        var wholeTestHtml = '';

        if(reportInfo.authNeg!=null){
            funcs = funcs + "-" +"认证协商";
            var times = 0.0;
            var len = getLength(reportInfo.authNegMap);
            var count = 0;
            if('0-RTT'==reportInfo.authNeg.method){
                for(var i in reportInfo.authNegMap){
                    var authNegoInfo = reportInfo.authNegMap[i];
                    if(authNegoInfo.result!="success"){
                        ANTestHtml = ANTestHtml+'<tr>\
                						<td class="bottom-td report-td w33" rowspan="1">第'+(parseInt(i)+parseInt(1)).toString()+'次'+authNegoInfo.method+'认证协商测试(共'+len+'次)</td>\
										 <td class="bottom-td report-td w33">单项测试</td>\
										 <td class="bottom-td report-td w33">'+resultTab[authNegoInfo.result]+'</td>\
										</tr>';
					}else {
                    	count = count+1;
                        times = times + parseFloat(authNegoInfo.time);
                        ANTestHtml = ANTestHtml+'<tr>\
                						<td class="bottom-td report-td w33" rowspan="9">第'+(parseInt(i)+parseInt(1)).toString()+'次'+authNegoInfo.method+'认证协商测试(共'+len+'次)</td>\
										 <td class="report-td w33">单项测试</td>\
										 <td class="report-td w33">'+resultTab[authNegoInfo.result]+'</td>\
										</tr>\
                						<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">'+authNegoInfo.startTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">'+authNegoInfo.endTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">'+authNegoInfo.time+' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">密钥</td>\
										 <td class="report-td w33">'+authNegoInfo.key+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">客户端协商种子</td>\
										 <td class="report-td w33">'+authNegoInfo.clientSeed+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">服务端协商种子</td>\
										 <td class="report-td w33">'+authNegoInfo.serverSeed+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">中间密钥SS</td>\
										 <td class="report-td w33">'+authNegoInfo.SS+'</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">校验值</td>\
										 <td class="bottom-td report-td w33">'+authNegoInfo.mac+'</td>\
										</tr>';
					}

                }
                var averageTime = 0.0;
                if(count!=0){
                	averageTime = (parseFloat(times)/parseFloat(count)).toFixed(3);
				}
                ANTestHtml = ANTestHtml+'<tr>\
										 <td class="bottom-td report-td w33">'+len+'次'+authNegoInfo.method+'认证协商测试</td>\
										 <td class="bottom-td report-td w33">平均耗时</td>\
										 <td class="bottom-td report-td w33">'+averageTime+' ms</td>\
										</tr>';
                if(reportInfo.authNeg.result!="success"){
                    wholeTestResult = "fail";
                    wholeTestHtml = wholeTestHtml+'<tr>\
                						<td class="bottom-td report-td w33" rowspan="1">完整测试-'+reportInfo.authNeg.method+'认证协商测试</td>\
										 <td class="bottom-td report-td w33">认证协商测试</td>\
										 <td class="bottom-td report-td w33">'+resultTab[reportInfo.authNeg.result]+'</td>\
										</tr>';
                }else {
                    wholeTestHtml = wholeTestHtml+'<tr>\
                						<td class="bottom-td report-td w33" rowspan="9">完整测试-'+reportInfo.authNeg.method+'认证协商测试</td>\
										 <td class="report-td w33">认证协商测试</td>\
										 <td class="report-td w33">'+resultTab[reportInfo.authNeg.result]+'</td>\
										</tr>\
                						<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.startTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.endTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.time+' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">密钥</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.key+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">客户端协商种子</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.clientSeed+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">服务端协商种子</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.serverSeed+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">中间密钥SS</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.SS+'</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">校验值</td>\
										 <td class="bottom-td report-td w33">'+reportInfo.authNeg.mac+'</td>\
										</tr>';
				}


            }else {
                for(var i in reportInfo.authNegMap) {
                    var authNegoInfo = reportInfo.authNegMap[i];
                    if(authNegoInfo.result!="success"){
                        ANTestHtml = ANTestHtml+'<tr>\
                						<td class="bottom-td report-td w33" rowspan="1">第'+(parseInt(i)+parseInt(1)).toString()+'次'+authNegoInfo.method+'认证协商测试(共'+len+'次)</td>\
										 <td class="bottom-td report-td w33">单项测试</td>\
										 <td class="bottom-td report-td w33">'+resultTab[authNegoInfo.result]+'</td>\
										</tr>';
                    }else{
                    	count = count+1;
                        times = times + parseFloat(authNegoInfo.time);
                        ANTestHtml = ANTestHtml+'<tr>\
                						<td class="bottom-td report-td w33" rowspan="8">第'+(parseInt(i)+parseInt(1)).toString()+'次'+authNegoInfo.method+'认证协商测试(共'+len+'次)</td>\
										 <td class="report-td w33">单项测试</td>\
										 <td class="report-td w33">'+resultTab[authNegoInfo.result]+'</td>\
										</tr>\
                						<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">'+authNegoInfo.startTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">'+authNegoInfo.endTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">'+authNegoInfo.time+' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">密钥</td>\
										 <td class="report-td w33">'+authNegoInfo.key+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">客户端协商种子</td>\
										 <td class="report-td w33">'+authNegoInfo.clientSeed+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">服务端协商种子</td>\
										 <td class="report-td w33">'+authNegoInfo.serverSeed+'</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">校验值</td>\
										 <td class="bottom-td report-td w33">'+authNegoInfo.mac+'</td>\
										</tr>';
					}

                }
                var averageTime = 0.0;
                if(count!=0){
                    averageTime = (parseFloat(times)/parseFloat(count)).toFixed(3);
                }
                ANTestHtml = ANTestHtml+'<tr>\
										 <td class="bottom-td report-td w33">'+len+'次'+authNegoInfo.method+'认证协商测试</td>\
										 <td class="bottom-td report-td w33">平均耗时</td>\
										 <td class="bottom-td report-td w33">'+averageTime+' ms</td>\
										</tr>';
                if(reportInfo.authNeg.result!="success"){
                    wholeTestResult = "fail";
                    wholeTestHtml = wholeTestHtml+'<tr>\
                						<td class="bottom-td report-td w33" rowspan="1">完整测试-'+reportInfo.authNeg.method+'认证协商测试</td>\
										 <td class="bottom-td report-td w33">认证协商测试</td>\
										 <td class="bottom-td report-td w33">'+resultTab[reportInfo.authNeg.result]+'</td>\
										</tr>';
                }else {
                    wholeTestHtml = wholeTestHtml+'<tr>\
                						<td class="bottom-td report-td w33" rowspan="8">完整测试-'+reportInfo.authNeg.method+'认证协商测试</td>\
										 <td class="report-td w33">认证协商测试</td>\
										 <td class="report-td w33">'+resultTab[reportInfo.authNeg.result]+'</td>\
										</tr>\
                						<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.startTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.endTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.time+' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">密钥</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.key+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">客户端协商种子</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.clientSeed+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">服务端协商种子</td>\
										 <td class="report-td w33">'+reportInfo.authNeg.serverSeed+'</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">校验值</td>\
										 <td class="bottom-td report-td w33">'+reportInfo.authNeg.mac+'</td>\
										</tr>';
				}


            }


            var attack = authNegoInfo.attack;
            var attackInfo = authNegoInfo.attackInfo;
            if(attack==""||attackInfo==""){
                attack = "无";
                attackInfo = "无";
            }
            ANAttHtml = '<tr>\
            							<td class="bottom-td report-td w33">'+authNegoInfo.method+' 认证协商</td>\
										 <td class="bottom-td report-td w33">'+attack+'</td>\
										 <td class="bottom-td report-td w33">'+attackInfo+'</td>\
										</tr>';

            ANConfigHtml = '<tr>\
            							<td class="bottom-td report-td w33">认证协商</td>\
										 <td class="bottom-td report-td w33">协商方式</td>\
										 <td class="bottom-td report-td w33">'+configInfo.authType+'</td>\
										</tr>';
        }

        if(reportInfo.encrypt!=null){

            funcs = funcs + "-" +"加密协商";
            var range = configInfo.encrypt.range=='0'?'DATA_AREA':'WHOLE_AREA';
            var times = 0.0;
            var count = 0;
            var len = getLength(reportInfo.encryptNegMap);
            for(var i in reportInfo.encryptNegMap){
                var encryptNegInfo = reportInfo.encryptNegMap[i];
                if(encryptNegInfo.result!="success"){
                    ENTestHtml = ENTestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="1">第'+(parseInt(i)+parseInt(1)).toString()+'次加密协商测试(共'+len+'次)</td>\
										 <td class="bottom-td report-td w33">单项测试</td>\
										 <td class="bottom-td report-td w33">'+resultTab[encryptNegInfo.result]+'</td>\
										</tr>';
				}else {
                	count = count +1;
                    times = times + parseFloat(encryptNegInfo.time);

                    ENTestHtml = ENTestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="5">第'+(parseInt(i)+parseInt(1)).toString()+'次加密协商测试(共'+len+'次)</td>\
										 <td class="report-td w33">单项测试</td>\
										 <td class="report-td w33">'+resultTab[encryptNegInfo.result]+'</td>\
										</tr>\
            							<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">'+encryptNegInfo.startTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">'+encryptNegInfo.endTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">'+encryptNegInfo.time+' ms</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">协商内容</td>\
										 <td class="bottom-td report-td w33">'+configInfo.encrypt.algorithm+'-'+configInfo.encrypt.mode+'-'+configInfo.encrypt.output+'-'+range+'</td>\
										</tr>';
				}

            }
            var averageTime = 0.0;
            if(count!=0){
                averageTime = (parseFloat(times)/parseFloat(count)).toFixed(3);
            }
            ENTestHtml = ENTestHtml+'<tr>\
										 <td class="bottom-td report-td w33">'+len+'次加密协商测试</td>\
										 <td class="bottom-td report-td w33">平均耗时</td>\
										 <td class="bottom-td report-td w33">'+averageTime+' ms</td>\
										</tr>';
            if(reportInfo.encryptNeg.result!="success"){
                wholeTestResult = "fail";
                wholeTestHtml = wholeTestHtml +'<tr>\
            							<td class="bottom-td report-td w33" rowspan="1">完整测试-加密协商测试</td>\
										 <td class="bottom-td report-td w33">加密协商测试</td>\
										 <td class="bottom-td report-td w33">'+resultTab[reportInfo.encryptNeg.result]+'</td>\
										</tr>';
            }else {
                wholeTestHtml = wholeTestHtml +'<tr>\
            							<td class="bottom-td report-td w33" rowspan="5">完整测试-加密协商测试</td>\
										 <td class="report-td w33">加密协商测试</td>\
										 <td class="report-td w33">'+resultTab[reportInfo.encryptNeg.result]+'</td>\
										</tr>\
            							<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">'+reportInfo.encryptNeg.startTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">'+reportInfo.encryptNeg.endTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">'+reportInfo.encryptNeg.time+' ms</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">协商内容</td>\
										 <td class="bottom-td report-td w33">'+configInfo.encrypt.algorithm+'-'+configInfo.encrypt.mode+'-'+configInfo.encrypt.output+'-'+range+'</td>\
										</tr>';
			}


        }
        if(reportInfo.exception!=null){
            funcs = funcs + "-" +"异常检测";
            var times = 0.0;
            var count = 0;
            var len = getLength(reportInfo.exceptionMap);
            for(var i in reportInfo.exceptionMap) {
                var exceptionInfo = reportInfo.exceptionMap[i];
                if(exceptionInfo.result!="success"){
                    EXTestHtml = EXTestHtml + '<tr>\
            							<td class="bottom-td report-td w33" rowspan="1">第' + (parseInt(i) + parseInt(1)).toString() + '次异常检测测试(共' + len + '次)</td>\
										 <td class="bottom-td report-td w33">单项测试</td>\
										 <td class="bottom-td report-td w33">' + resultTab[exceptionInfo.result] + '</td>\
										</tr>';
				}else {
                	count = count +1;
                    times = times + parseFloat(exceptionInfo.time);
                    EXTestHtml = EXTestHtml + '<tr>\
            							<td class="bottom-td report-td w33" rowspan="8">第' + (parseInt(i) + parseInt(1)).toString() + '次异常检测测试(共' + len + '次)</td>\
										 <td class="report-td w33">单项测试</td>\
										 <td class="report-td w33">' + resultTab[exceptionInfo.result] + '</td>\
										</tr>\
            							<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">' + exceptionInfo.startTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">' + exceptionInfo.endTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">' + exceptionInfo.time + ' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">头部长度</td>\
										 <td class="report-td w33">' + exceptionInfo.headLength + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">数据长度</td>\
										 <td class="report-td w33">' + exceptionInfo.totalLength + '</td>\
										</tr>\
									    <tr>\
										 <td class="report-td w33">实际数据长度</td>\
										 <td class="report-td w33">' + exceptionInfo.actualLength + '</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">头部信息</td>\
										 <td class="bottom-td report-td w33">' + exceptionInfo.headInfo + '</td>\
										</tr>';
				}

            }
            var averageTime = 0.0;
            if(count!=0){
                averageTime = (parseFloat(times)/parseFloat(count)).toFixed(3);
            }
            EXTestHtml = EXTestHtml+'<tr>\
										 <td class="bottom-td report-td w33">'+len+'次异常检测测试</td>\
										 <td class="bottom-td report-td w33">平均耗时</td>\
										 <td class="bottom-td report-td w33">'+averageTime+' ms</td>\
										</tr>';
            if(reportInfo.exception.result!="success"){
                wholeTestResult = "fail";
                wholeTestHtml = wholeTestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="1">完整测试-异常检测测试</td>\
										 <td class="bottom-td report-td w33">异常检测测试</td>\
										 <td class="bottom-td report-td w33">'+resultTab[reportInfo.exception.result]+'</td>\
										</tr>';
            }else {
                wholeTestHtml = wholeTestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="8">完整测试-异常检测测试</td>\
										 <td class="report-td w33">异常检测测试</td>\
										 <td class="report-td w33">'+resultTab[reportInfo.exception.result]+'</td>\
										</tr>\
            							<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">'+reportInfo.exception.startTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">'+reportInfo.exception.endTime+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">'+reportInfo.exception.time+' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">头部长度</td>\
										 <td class="report-td w33">'+reportInfo.exception.headLength+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">数据长度</td>\
										 <td class="report-td w33">'+reportInfo.exception.totalLength+'</td>\
										</tr>\
									    <tr>\
										 <td class="report-td w33">实际数据长度</td>\
										 <td class="report-td w33">'+reportInfo.exception.actualLength+'</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">头部信息</td>\
										 <td class="bottom-td report-td w33">'+reportInfo.exception.headInfo+'</td>\
										</tr>';
			}


            var attack = exceptionInfo.attack;
            var attackInfo = exceptionInfo.attackInfo;
            if(attack==""||attackInfo==""){
                attack = "无";
                attackInfo = "无";
            }
            EXAttHtml = '<tr>\
            							<td class="bottom-td report-td w33">异常检测</td>\
										 <td class="bottom-td report-td w33">'+attack+'</td>\
										 <td class="bottom-td report-td w33">'+attackInfo+'</td>\
										</tr>';

			/*encodeInfo.encodeException_val*/
            var exMethod = '0'==configInfo.exception.method?'数据包头溢出':'字段类型合法性';
			/*EXCodeHtml = '<tr>\
			 <td class="bottom-td report-td w25">异常检测</td>\
			 <td class="bottom-td report-td w25">检测方式位</td>\
			 <td class="bottom-td report-td w25">'+exMethod+'</td>\
			 <td class="bottom-td report-td w25">'+exceptionFunc[exMethod]+'</td>\
			 </tr>';*/

            EXConfigHtml = '<tr>\
            							<td class="bottom-td report-td w33">异常检测</td>\
										 <td class="bottom-td report-td w33">检测方式</td>\
										 <td class="bottom-td report-td w33">'+exMethod+'</td>\
										</tr>';
        }
        if(reportInfo.integrity!=null){
            funcs = funcs + "-" +"完整性校验";
            var times = 0.0;
            var count = 0;
            var len = getLength(reportInfo.integrityMap);
            for(var i in reportInfo.integrityMap) {
                var integrityInfo = reportInfo.integrityMap[i];
                if(integrityInfo.result!="success"){
                    ITestHtml = ITestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="1">第'+(parseInt(i)+parseInt(1)).toString()+'次完整性校验测试(共'+len+'次)</td>\
										 <td class="bottom-td report-td w33">单项测试</td>\
										 <td class="bottom-td report-td w33">' + resultTab[integrityInfo.result] + '</td>\
										</tr>';
				}else {
                	count = count+1;
                    times = times + parseFloat(integrityInfo.time);
                    ITestHtml = ITestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="8">第'+(parseInt(i)+parseInt(1)).toString()+'次完整性校验测试(共'+len+'次)</td>\
										 <td class="report-td w33">单项测试</td>\
										 <td class="report-td w33">' + resultTab[integrityInfo.result] + '</td>\
										</tr>\
            							<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">' + integrityInfo.startTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">' + integrityInfo.endTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">' + integrityInfo.time + ' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">校验算法</td>\
										 <td class="report-td w33">' + integrityInfo.method + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">摘要值</td>\
										 <td class="report-td w33">' + integrityInfo.hashValue + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">校验值</td>\
										 <td class="report-td w33">' + integrityInfo.verifyValue + '</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">数据部分</td>\
										 <td class="bottom-td report-td w33">' + integrityInfo.content + '</td>\
										</tr>';
				}

            }
            var averageTime = 0.0;
            if(count!=0){
                averageTime = (parseFloat(times)/parseFloat(count)).toFixed(3);
            }
            ITestHtml = ITestHtml+'<tr>\
										 <td class="bottom-td report-td w33">'+len+'次完整性校验测试</td>\
										 <td class="bottom-td report-td w33">平均耗时</td>\
										 <td class="bottom-td report-td w33">'+averageTime+' ms</td>\
										</tr>';
            if(reportInfo.integrity.result!="success"){
                wholeTestResult = "fail";
                wholeTestHtml = wholeTestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="1">完整测试-完整性校验测试</td>\
										 <td class="bottom-td report-td w33">完整性校验测试</td>\
										 <td class="bottom-td report-td w33">' + resultTab[reportInfo.integrity.result] + '</td>\
										</tr>';
            }else {
                wholeTestHtml = wholeTestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="8">完整测试-完整性校验测试</td>\
										 <td class="report-td w33">完整性校验测试</td>\
										 <td class="report-td w33">' + resultTab[reportInfo.integrity.result] + '</td>\
										</tr>\
            							<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">' + reportInfo.integrity.startTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">' + reportInfo.integrity.endTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">' + reportInfo.integrity.time + ' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">校验算法</td>\
										 <td class="report-td w33">' + reportInfo.integrity.method + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">摘要值</td>\
										 <td class="report-td w33">' + reportInfo.integrity.hashValue + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">校验值</td>\
										 <td class="report-td w33">' + reportInfo.integrity.verifyValue + '</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">数据部分</td>\
										 <td class="bottom-td report-td w33">' + reportInfo.integrity.content + '</td>\
										</tr>';
			}


            var attack = integrityInfo.attack;
            var attackInfo = integrityInfo.attackInfo;
            if(attack==""||attackInfo==""){
                attack = "无";
                attackInfo = "无";
            }
            IAttHtml = '<tr>\
            							<td class="bottom-td report-td w33">完整性校验</td>\
										 <td class="bottom-td report-td w33">'+attack+'</td>\
										 <td class="bottom-td report-td w33">'+attackInfo+'</td>\
										</tr>';
			/*ICodeHtml = '<tr>\
			 <td class="bottom-td report-td w25">完整性校验</td>\
			 <td class="bottom-td report-td w25">校验算法位</td>\
			 <td class="bottom-td report-td w25">'+configInfo.integrity.algorithm+'</td>\
			 <td class="bottom-td report-td w25">'+integrityFunc[configInfo.integrity.algorithm]+'</td>\
			 </tr>';*/
            IConfigHtml = '<tr>\
            							<td class="bottom-td report-td w33">完整性校验</td>\
										 <td class="bottom-td report-td w33">校验算法</td>\
										 <td class="bottom-td report-td w33">'+configInfo.integrity.algorithm+'(base64输出,取4位)</td>\
										</tr>';
        }
        if(reportInfo.encrypt!=null){
            funcs = funcs + "-" +"加密";
            var times = 0.0;
            var count = 0;
            var len = getLength(reportInfo.encryptMap);
            for(var i in reportInfo.encryptMap) {
                var encryptInfo = reportInfo.encryptMap[i];
                if (encryptInfo.result!="success"){
                    ETestHtml = ETestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="1">第'+(parseInt(i)+parseInt(1)).toString()+'次加密测试(共'+len+'次)</td>\
										 <td class="bottom-td report-td w33">单项测试</td>\
										 <td class="bottom-td report-td w33">' + resultTab[encryptInfo.result] + '</td>\
										</tr>';
				}else {
                	count = count +1;
                    times = times + parseFloat(encryptInfo.time);
                    ETestHtml = ETestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="8">第'+(parseInt(i)+parseInt(1)).toString()+'次加密测试(共'+len+'次)</td>\
										 <td class="report-td w33">单项测试</td>\
										 <td class="report-td w33">' + resultTab[encryptInfo.result] + '</td>\
										</tr>\
            							<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">' + encryptInfo.startTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">' + encryptInfo.endTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">' + encryptInfo.time + ' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">加密算法</td>\
										 <td class="report-td w33">' + encryptInfo.method + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">加密前数据</td>\
										 <td class="report-td w33">' + encryptInfo.before + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">加密后数据</td>\
										 <td class="report-td w33">' + encryptInfo.after + '</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">加密密钥</td>\
										 <td class="bottom-td report-td w33">' + encryptInfo.key + '</td>\
										</tr>';
				}

            }
            var averageTime = 0.0;
            if(count!=0){
                averageTime = (parseFloat(times)/parseFloat(count)).toFixed(3);
            }
            ETestHtml = ETestHtml+'<tr>\
										 <td class="bottom-td report-td w33">'+len+'次加密测试</td>\
										 <td class="bottom-td report-td w33">平均耗时</td>\
										 <td class="bottom-td report-td w33">'+averageTime+' ms</td>\
										</tr>';
            if(reportInfo.encrypt.result!="success"){
                wholeTestResult = "fail";
                wholeTestHtml = wholeTestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="1">完整测试-加密测试</td>\
										 <td class="bottom-td report-td w33">加密测试</td>\
										 <td class="bottom-td report-td w33">' + resultTab[reportInfo.encrypt.result] + '</td>\
										</tr>';
            }else {
                wholeTestHtml = wholeTestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="8">完整测试-加密测试</td>\
										 <td class="report-td w33">加密测试</td>\
										 <td class="report-td w33">' + resultTab[reportInfo.encrypt.result] + '</td>\
										</tr>\
            							<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">' + reportInfo.encrypt.startTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">' + reportInfo.encrypt.endTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">' + reportInfo.encrypt.time + ' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">加密算法</td>\
										 <td class="report-td w33">' + reportInfo.encrypt.method + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">加密前数据</td>\
										 <td class="report-td w33">' + reportInfo.encrypt.before + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">加密后数据</td>\
										 <td class="report-td w33">' + reportInfo.encrypt.after + '</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">加密密钥</td>\
										 <td class="bottom-td report-td w33">' + reportInfo.encrypt.key + '</td>\
										</tr>';
			}


            var attack = encryptInfo.attack;
            var attackInfo = encryptInfo.attackInfo;
            if(attack==""||attackInfo==""){
                attack = "无";
                attackInfo = "无";
            }
            EAttHtml = '<tr>\
            							<td class="bottom-td report-td w33">加密</td>\
										 <td class="bottom-td report-td w33">'+attack+'</td>\
										 <td class="bottom-td report-td w33">'+attackInfo+'</td>\
										</tr>';
			/*ECodeHtml = '<tr>\
			 <td class="bottom-td report-td w25" rowspan="4">加密</td>\
			 <td class="report-td w25">加密算法位-加密模式位</td>\
			 <td class="report-td w25">'+encodeInfo.encodeEncryAlg_key+'-'+encodeInfo.encodeEncryModel_key+'</td>\
			 <td class="report-td w25">'+encryptFunc[encodeInfo.encodeEncryAlg_key+'-'+encodeInfo.encodeEncryModel_key]+'</td>\
			 </tr>\
			 <tr>\
			 <td class="bottom-td report-td w25">加密输出格式位</td>\
			 <td class="bottom-td report-td w25">'+configInfo.encrypt.output+'</td>\
			 <td class="bottom-td report-td w25">'+encryptOutput[configInfo.encrypt.output=="base64"?"Base64":"Hex"]+'</td>\
			 </tr>';*/
			/*\
			 <tr>\
			 <td class="bottom-td report-td w25">异常检测结果</td>\
			 <td class="bottom-td report-td w25">'+encodeInfo.encodeEncryArea_key+'</td>\
			 <td class="bottom-td report-td w25">'+encodeInfo.encodeEncryArea_val+'</td>\
			 </tr>*/
            var area = '0'==configInfo.encrypt.range?'加密协议数据部分':'加密整个协议报文';
            EConfigHtml = '<tr>\
										 <td class="bottom-td report-td w33" rowspan="4">加密</td>\
										 <td class="report-td w33">加密算法</td>\
										 <td class="report-td w33">'+configInfo.encrypt.algorithm+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">加密模式</td>\
										 <td class="report-td w33">'+configInfo.encrypt.mode+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">输出格式</td>\
										 <td class="report-td w33">'+configInfo.encrypt.output+'</td>\
										</tr>\
            							<tr>\
            							 <td class="bottom-td report-td w33">加密区域</td>\
										 <td class="bottom-td report-td w33">'+area+'</td>\
										</tr>';
        }
        if(reportInfo.resend!=null){
            funcs = funcs + "-" +"通信重传";
            var times = 0.0;
            var count = 0;
            var len = getLength(reportInfo.resendMap);
            for(var i in reportInfo.resendMap) {
                var resendInfo = reportInfo.resendMap[i];
                if(resendInfo.result!="success"){
                    RTestHtml = RTestHtml + '<tr>\
            							<td class="bottom-td report-td w33" rowspan="1">第' + (parseInt(i) + parseInt(1)).toString() + '次通信重传测试(共' + len + '次)</td>\
										 <td class="bottom-td report-td w33">单项测试</td>\
										 <td class="bottom-td report-td w33">' + resultTab[resendInfo.result] + '</td>\
										</tr>';
				}else {
                	count = count +1;
                    times = times + parseFloat(resendInfo.time);
                    RTestHtml = RTestHtml + '<tr>\
            							<td class="bottom-td report-td w33" rowspan="9">第' + (parseInt(i) + parseInt(1)).toString() + '次通信重传测试(共' + len + '次)</td>\
										 <td class="report-td w33">单项测试</td>\
										 <td class="report-td w33">' + resultTab[resendInfo.result] + '</td>\
										</tr>\
            							<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">' + resendInfo.startTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">' + resendInfo.endTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">' + resendInfo.time + ' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">重传次数</td>\
										 <td class="report-td w33">' + resendInfo.count + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">成功重传次数</td>\
										 <td class="report-td w33">' + resendInfo.successCount + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">重传序列</td>\
										 <td class="report-td w33">' + resendInfo.sequence + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">队列长度</td>\
										 <td class="report-td w33">' + resendInfo.queue + '</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">超时时限</td>\
										 <td class="bottom-td report-td w33">' + resendInfo.RTO + '</td>\
										</tr>';
				}

            }
            var averageTime = 0.0;
            if(count!=0){
                averageTime = (parseFloat(times)/parseFloat(count)).toFixed(3);
            }
            RTestHtml = RTestHtml+'<tr>\
										 <td class="bottom-td report-td w33">'+len+'次重传测试</td>\
										 <td class="bottom-td report-td w33">平均耗时</td>\
										 <td class="bottom-td report-td w33">'+averageTime+' ms</td>\
										</tr>';
            if(reportInfo.resend.result!="success"){
                wholeTestResult = "fail";
                wholeTestHtml = wholeTestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="1">完整测试-重传测试</td>\
										 <td class="bottom-td report-td w33">重传测试</td>\
										 <td class="bottom-td report-td w33">' + resultTab[reportInfo.resend.result] + '</td>\
										</tr>';
            }else {
                wholeTestHtml = wholeTestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="9">完整测试-重传测试</td>\
										 <td class="report-td w33">重传测试</td>\
										 <td class="report-td w33">' + resultTab[reportInfo.resend.result] + '</td>\
										</tr>\
            							<tr>\
										 <td class="report-td w33">开始时间</td>\
										 <td class="report-td w33">' + reportInfo.resend.startTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">结束时间</td>\
										 <td class="report-td w33">' + reportInfo.resend.endTime + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">耗时</td>\
										 <td class="report-td w33">' + reportInfo.resend.time + ' ms</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">重传次数</td>\
										 <td class="report-td w33">' + reportInfo.resend.count + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">成功重传次数</td>\
										 <td class="report-td w33">' + reportInfo.resend.successCount + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">重传序列</td>\
										 <td class="report-td w33">' + reportInfo.resend.sequence + '</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">重传队列长度</td>\
										 <td class="report-td w33">' + reportInfo.resend.queue + '</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">超时时限</td>\
										 <td class="bottom-td report-td w33">' + reportInfo.resend.RTO + '</td>\
										</tr>';
			}


            var attack = resendInfo.attack;
            var attackInfo = resendInfo.attackInfo;
            if(attack==""||attackInfo==""){
                attack = "无";
                attackInfo = "无";
            }
            RAttHtml = '<tr>\
            							<td class="report-td w33">通信重传</td>\
										 <td class="report-td w33">'+attack+'</td>\
										 <td class="report-td w33">'+attackInfo+'</td>\
										</tr>';

            RConfigHtml = '<tr>\
										 <td class="bottom-td report-td w33" rowspan="3">通信重传</td>\
										 <td class="report-td w33">队列长度</td>\
										 <td class="report-td w33">'+configInfo.resend.queue+'</td>\
										</tr>\
										<tr>\
										 <td class="report-td w33">超时时限</td>\
										 <td class="report-td w33">'+configInfo.resend.time+' ms</td>\
										</tr>\
            							<tr>\
            							<td class="bottom-td report-td w33">重传次数</td>\
										 <td class="bottom-td report-td w33">'+configInfo.resend.count+'</td>\
										</tr>';
        }

        wholeTestHtml = wholeTestHtml+'<tr>\
            							<td class="bottom-td report-td w33" rowspan="3">完整测试</td>\
										 <td class="report-td w33">测试结果</td>\
										 <td class="report-td w33">'+resultTab[wholeTestResult]+'</td>\
										</tr>\
										<td class="report-td w33">测试项</td>\
										 <td class="report-td w33">'+funcs.substr(1)+'</td>\
										</tr>\
										<tr>\
										 <td class="bottom-td report-td w33">整体耗时</td>\
										 <td class="bottom-td report-td w33">'+reportInfo.wholeTime+' ms</td>\
										</tr>';


        var dialogHtml = '<div style="display: block;">\
						<div id="dlg-report"  class="easyui-dialog" closed="true" title="测试报告" style="top:80px; max-width: 100%; min-height: 200px; padding: 20px;">\
							<h1>编号T-'+(reportInfo["id"].substr(6,2)+reportInfo["id"].substr(-6)).toUpperCase()+'测试报告</h1>\
							<h4 style="margin-top: 10px">参数列表</h4>\
							<div class="offcial-table margin-top clearfix">\
								<div class="offcial-table tr-border margin-big-top clearfix">\
									<div class="tr-th clearfix">\
										<div class="th w33">序号</div>\
										<div class="th w33">协议名</div>\
										<div class="th w33">测试功能</div>\
									</div>\
									<div class="tr clearfix border-bottom-none">\
										<table class="report-table">\
												 <tr>\
												 <td class="report-td w33">'+(reportInfo["id"].substr(6,2)+reportInfo["id"].substr(-6)).toUpperCase()+'</td>\
												 <td class="report-td w33">'+reportInfo["protocolName"]+'</td>\
												 <td class="report-td w33">'+funcs.substr(1)+'</td>\
												</tr>\
										</table>\
									</div>\
								</div>\
							</div>\
							<h4 style="margin-top: 10px">协议配置</h4>\
							<div class="offcial-table margin-top clearfix">\
								<div class="offcial-table tr-border margin-big-top clearfix">\
									<div class="tr-th clearfix">\
										<div class="th w33">安全策略</div>\
										<div class="th w33">参数名称</div>\
										<div class="th w33">参数值</div>\
									</div>\
									<div class="tr clearfix border-bottom-none">\
										<table class="report-table">'+ANConfigHtml+EXConfigHtml+IConfigHtml+EConfigHtml+RConfigHtml+'</table>\
									</div>\
								</div>\
							</div>\
							<h4 style="margin-top: 10px">协议单项测试</h4>\
							<div class="offcial-table margin-top clearfix">\
								<div class="offcial-table tr-border margin-big-top clearfix">\
									<div class="tr-th clearfix">\
										<div class="th w33">测试项</div>\
										<div class="th w33">测试内容</div>\
										<div class="th w33">测试结果</div>\
									</div>\
									<div class="tr clearfix border-bottom-none">\
										<table class="report-table">'+ANTestHtml+ENTestHtml+EXTestHtml+ITestHtml+ETestHtml+RTestHtml+'</table>\
									</div>\
								</div>\
							</div>\
							<h4 style="margin-top: 10px">协议完整测试</h4>\
							<div class="offcial-table margin-top clearfix">\
								<div class="offcial-table tr-border margin-big-top clearfix">\
									<div class="tr-th clearfix">\
										<div class="th w33">测试项</div>\
										<div class="th w33">测试内容</div>\
										<div class="th w33">测试结果</div>\
									</div>\
									<div class="tr clearfix border-bottom-none">\
										<table class="report-table">'+wholeTestHtml+'</table>\
									</div>\
								</div>\
							</div>\
							<h4 style="margin-top: 10px">协议抵御攻击测试</h4>\
							<div class="offcial-table margin-top clearfix">\
								<div class="offcial-table tr-border margin-big-top clearfix">\
									<div class="tr-th clearfix">\
										<div class="th w33">攻击对象</div>\
										<div class="th w33">攻击类型</div>\
										<div class="th w33">攻击过程信息</div>\
									</div>\
									<div class="tr clearfix border-bottom-none">\
										<table class="report-table">'+ANAttHtml+EXAttHtml+IAttHtml+EAttHtml+RAttHtml+'</table>\
									</div>\
								</div>\
							</div>\
						</div>\
					</div>';

        $("#reportbody").append(dialogHtml);
        /*var dlgcontent = $("#dlg-report").html();
        $("#dlg-report").dialog({
            content: dlgcontent,
            onClose: function () {
                $("#dlg-report").remove();
            }
        });
        $("#dlg-report").dialog("open");*/
    }else{
        alert("查询报告详情有误！");
        window.location.href = "test.html";
    }

}


function addContent(res){
    //查询成功
    if(res.meta.state==="success") {
        var list = res.data;
        if(list.length==0){
            alert("已经是最后一页!");
            num--;
        }else{
            console.log("有查询记录");
            console.log(list);
            $("#tbody").empty();
            $("#pageNum").text(num);
            for(var p in list){
                //一条数据
                var item = list[p];
                var id = item["id"];
                var protocolName  = item["protocolName"];
                var designId = item["designId"];
                var functions = item["functions"];
                var funcList = new Array();
                for(var func in functions){
                    var funcName = funcTab[functions[func]];
                    if(undefined!=funcName){
                        funcList.push(funcName);
                    }
                }

                var createTime = item["createTime"];
                var reportsHtml = '<div class="tr clearfix border-bottom-none">\
								<div class="td w5">\
									<input type="checkbox" value="'+id+'"/>\
								</div>\
								<div class="td w15">T-'+(id.substr(6,2)+id.substr(-6)).toUpperCase()+'</div>\
								<div class="td w15">D-'+(designId.substr(6,2)+designId.substr(-6)).toUpperCase()+'</div>\
								<div class="td w15">'+protocolName+'</div>\
								<div class="td w25">'+funcList.toString()+'</div>\
								<div class="td w15">'+createTime+'</div>\
								<div class="td w10">\
									<div style="display: inline-block;" class="myIcon"\
										 onclick="getReportDetail(\''+id+'\',\''+designId+'\')">\
										<a href="javascript:;">\
											<i class="fa fa-search fa-lg" title="查看详情">\
											</i>\
										</a>\
									</div>\
									<div style="display: inline-block;" class="myIcon">\
										<a onclick="deleteTestReport(\''+id+'\')" data-id="" >\
											<i class="fa fa-trash fa-lg" title="删除测试报告">\
											</i>\
										</a>\
									</div>\
								</div>\
							</div>';
                $("#tbody").append(reportsHtml);
            }
        }

    }else if(res.meta.message!="notlogin"){
        alert("已经是最后一页!");
        num--;
    }
}
/**
 * 删除多条测试报告
 */
function deleteTestReports(){
    //if(confirm("确认删除所选测试报告吗？")) {
    var ids = "";
    $.each($("#tbody input[type='checkbox']:checked"), function() {
        if(ids == "") {
            ids = ids + $(this).val();
        } else {
            ids = ids + "," + $(this).val();
        }
    });
    $.ajax({
        url: HOST.concat("/testReports?token=" + config.token),
        type: "DELETE",
        data: {
            "idList":ids
        },
        success: function(datas){
            checkLogin(datas);
            window.location.reload();
        },
        error: function(){
            console.log("删除测试报告错误！");
        },
        dataType: "json",
    });
    //}
}
/**
 * 删除一条测试报告
 */
function deleteTestReport(reportId){
    //if(confirm("确认删除所选测试报告吗？")) {
    $.ajax({
        url: HOST.concat("/testReports/id?token=" + config.token),
        type: "DELETE",
        data: {
            "id":reportId
        },
        success: function(datas){
            checkLogin(datas);
            window.location.reload();
        },
        error: function(){
            console.log("删除测试报告错误！");
        },
        dataType: "json",
    });
    //}
}

function getTestReports(num){
    listTestReport(num,pageSize);
}

function reportLastPage(){
    if(num<=1){
        num = 1;
        alert("已经是第一页!");
        $("#pageNum").text(num);
    }else{
        num--;
        getTestReports(num);
    }
}

function reportNextPage(){
    num++;
    getTestReports(num);
}
function reportFirstPage(){
    num = 1;
    $("#pageNum").text(num);
    getTestReports(num);
}
function showReportContent() {
    $.ajax({
        url: HOST.concat("/testReports/id?id="+reportId+"&token=" + config.token),
        type: "GET",
        async: false,
        success: function(datas){
            checkLogin(datas);
            console.log(datas);
            //getEncodeInfo(designId);
            getConfigInfo(designId);
            //getEncodeDesignInfo(designId);
            addDialogDiv(datas);

        },
        error: function(){
            console.log("请求测试报告详情错误!");
        },
        dataType: "json",
    });
}
